﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using CoreData;

namespace SchoolManagementSystem.Forms.BusinessForm
{
    public partial class frmInventory : DevExpress.XtraEditors.XtraForm
    {
        public frmInventory()
        {
            InitializeComponent();

            lookUpEdit_Room.Properties.DataSource = RegisterService.RegisterServices.ProductWareHouseService.GetListByParent(" where ParentID = 1");
            lookUpEdit_Room.Properties.ValueMember = "ID";
            lookUpEdit_Room.Properties.DisplayMember = "Name";
            lookUpEdit_Room.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Name", "Phòng"));
        }

        private void barButtonItem_AddNew_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            frmInventory_Detail frm = new frmInventory_Detail();
            frm.ShowDialog();
        }
        void LoadInStock()
        {
            IList<Inventory_Detail> dataDetail = new List<Inventory_Detail>();
            dataDetail = RegisterService.RegisterServices.Inventory_DetailService.GetList_ProductInRoom((long)lookUpEdit_Room.EditValue);
            gridControl1.DataSource = dataDetail;
            gridView1.RefreshData();
        }

        private void cmdFillter_Click(object sender, EventArgs e)
        {
           
        }

        private void lookUpEdit_Room_EditValueChanged(object sender, EventArgs e)
        {
            LoadInStock();
            gridControl2.DataSource = null;
        }

        private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            long _ProductID = (long)gridView1.GetRowCellValue(e.RowHandle, "ProductID");
            IList<Inventory_Detail> dataDetail = new List<Inventory_Detail>();
            dataDetail=RegisterService.RegisterServices.Inventory_DetailService.GetList_InventoryDetail((long)lookUpEdit_Room.EditValue,_ProductID);
            gridControl2.DataSource = dataDetail;
            gridView1.RefreshData();
        }
    }
}